/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.repair.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.modules.repair.entity.MaintainMalfunctionWork;
import org.springblade.modules.repair.entity.MaintainPlanContent;
import org.springblade.modules.repair.vo.*;
import org.springblade.modules.repair.vo.part.SearchPartsTreeVo;
import org.springblade.modules.repair.vo.plan.PlanPartStatusVo;
import org.springblade.modules.repair.vo.plan.wx.WxUserPlanVo;

import java.util.HashMap;
import java.util.List;

/**
 * 故障工单明细 服务类
 *
 * @author zcc
 * @since 2021-05-22
 */
public interface IMaintainMalfunctionWorkService extends BaseService<MaintainMalfunctionWork> {


	String WX_USER_PLAN_KEY="wx_user_plan:";

	/**
	 * 自定义分页
	 *
	 * @param page
	 * @param maintainMalfunctionWork
	 * @return
	 */
	IPage<MaintainMalfunctionWorkVO> selectMaintainMalfunctionWorkPage(IPage<MaintainMalfunctionWorkVO> page, MaintainMalfunctionWorkVO maintainMalfunctionWork);

	/**
	 * 查询工单明细
	 *
	 * @param planId 计划id
	 * @param userId 用户id
	 * @return 工单明细
	 */
	MalfunctionWorkDetailVo detailByPlanId(Long planId, Long userId);

	/**
	 * 新增报障
	 * @param repairWorkVO
	 * @return
	 */
	HashMap<String,Object> malfunctionWorkSave(RepairWorkVO repairWorkVO);


    MalFunctionDetailVO selectMalfunctionDetail(Long planId);

	MalFunctionDetailVO malfunctionDetail(Long planId);

    Boolean malfunctionFinish(MaintainMalfunctionWork entity);

	/**
	 * 重新分配任务
	 * @param repairWorkVO 参数
	 * @return 数据集
	 */
	boolean malfunctionWorkUpdate(RepairWorkVO repairWorkVO);


	MalFunctionApproveDetailVO malfunctionApproveDetail(Long planId);

	List<MalfunctionPartsTreeVO> selectMalPartsTree(String keyWord);


	List<SearchPartsTreeVo> selectMalPartsTreeV2(String keyWord);

	/**
	 * 根据工单id获取配件任务(未完成的)
	 * @param planId 工单id
	 * @return 数据集
	 */
	PlanPartStatusVo getPartListCounts(Long planId);

    Boolean updateMalDetail(MaintainMalfunctionWork malfunctionWork);

	/**
	 * 获取预计时间
	 * @param id 工单id
	 * @return 格式化好的预计时间
	 */
	String getPreTime(Long id);

	/**
	 * 根据工单id 获取 FaultFeedbackVO
	 * @param id 工单id
	 * @return faultFeedbackVO 对象
	 */
	FaultFeedbackVO getFeedbackMessage(Long id);

	/**
	 * 根据 工单 id 获取 approveStatus 信息
	 * @param id 工单id
	 * @return approveStatus 状态
	 */
	Integer getApproveStatus(Long id);

	/**
	 * 修改维修报障信息
	 * @param repairWorkVO 传入参数
	 * @return 是否成功
	 */
	boolean malfunctionWorkUpdateMessage(RepairWorkVO repairWorkVO);

	Long submitMalDetail(MaintainMalfunctionWork malfunctionWork);

	List<MaintainPlanContent> getPartList(Long planId);

	List<MaintainMalfunctionWork> listByPlanId(Long planId);

	/**
	 * 用户今日的工单列表
	 * @return 数据集
	 * @param buildingIds
	 */
	List<WxUserPlanVo> userPlanListOfToday(String buildingIds);



	/**
	 * 发送预警通知
	 * @param repairWorkVO 参数
	 * @param planId 工单id
	 */
	void sendYjMsg(RepairWorkVO repairWorkVO, Long planId);
}
